<!-- src/components/common/Loading.vue -->
<template>
  <div v-if="loading" class="loading-container">
    <div class="loading-content">
      <el-icon class="loading-icon" :size="32">
        <Loading />
      </el-icon>
      <p>{{ text || '加载中...' }}</p>
    </div>
  </div>
</template>

<script setup>
import { Loading } from '@element-plus/icons-vue'

defineProps({
  loading: {
    type: Boolean,
    default: false
  },
  text: {
    type: String,
    default: ''
  }
})
</script>

<style scoped>
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
}

.loading-icon {
  animation: rotate 1s linear infinite;
  color: #409EFF;
  margin-bottom: 10px;
}

.loading-content p {
  color: #606266;
  margin: 0;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>